package com.he.security.crypto.password;

import com.he.security.crypto.codec.utf8;

import java.security.MessageDigest;

class PasswordEncoderUtils {

    static boolean equals(String expected, String actual) {
        byte[] expectedBytes = bytesUtf8(expected);
        byte[] actualBytes = bytesUtf8(actual);
        return MessageDigest.isEqual(expectedBytes, actualBytes);
    }


    private static byte[] bytesUtf8(String s) {
        if (s == null) {
            return null;
        }
        return utf8.encode(s);
    }

    private PasswordEncoderUtils() {
    }
}
